unit DSim;

interface

implementation

uses Windows;

Var DelphiVer : String = '7';

const

ApplicationWindowClass :TWndClass = (
   style :0;
   lpfnWndProc :@DefWindowProc;
   cbClsExtra :0;
   cbWndExtra :0;
   hInstance :0;
   hIcon :0;
   hCursor :0;
   hbrBackground :0;
   lpszMenuName :'';
   lpszClassName :'Tapplication'
);

AppBuilderWindowClass :TWndClass = (
   style :0;
   lpfnWndProc :@DefWindowProc;
   cbClsExtra :0;
   cbWndExtra :0;
   hInstance :0;
   hIcon :0;
   hCursor :0;
   hbrBackground :0;
   lpszMenuName :'';
   lpszClassName :'Tappbuilder'
);

PropertyInspectorWindowClass :TWndClass = (
   style :0;
   lpfnWndProc :@DefWindowProc;
   cbClsExtra :0;
   cbWndExtra :0;
   hInstance :0;
   hIcon :0;
   hCursor :0;
   hbrBackground :0;
   lpszMenuName :'';
   lpszClassName :'TPropertyInspector'
);

AlignPaletteWindowClass :TWndClass = (
   style :0;
   lpfnWndProc :@DefWindowProc;
   cbClsExtra :0;
   cbWndExtra :0;
   hInstance :0;
   hIcon :0;
   hCursor :0;
   hbrBackground :0;
   lpszMenuName :'';
   lpszClassName :'TAlignPalette'
);

var AppBuilderHWND :HWND;
    PropertyInspectorHWND :HWND;
    AlignPaletteHWND :HWND;
    ApplicationHWND :HWND;

initialization
Begin
  { TApplication }
  if FindWindow(ApplicationWindowClass.lpszClassName,PChar('DELPHI '+DelphiVer)) = 0 then begin
     RegisterClass(ApplicationWindowClass);
     ApplicationHWND := CreateWindowEx(0, ApplicationWindowClass.lpszClassName,PChar('DELPHI '+DelphiVer),0,0,0,0,0,0,0,HInstance,NIL);
  end;

  { TAppBuilder }
  if FindWindow(AppBuilderWindowClass.lpszClassName,NIL) = 0 then begin
     RegisterClass(AppBuilderWindowClass);
     AppBuilderHWND := CreateWindowEx(0, AppBuilderWindowClass.lpszClassName,PChar('DELPHI '+DelphiVer+' - APP [running]'),0,0,0,0,0,0,0,HInstance,NIL);
  end;

  { TPropertyInspector }
  if FindWindow(PropertyInspectorWindowClass.lpszClassName,NIL) = 0 then begin
     RegisterClass(PropertyInspectorWindowClass);
     PropertyInspectorHWND := CreateWindowEx(0,PropertyInspectorWindowClass.lpszClassName,PChar('object inspector DELPHI '+DelphiVer),0,0,0,0,0,0,0,HInstance, NIL);
  end;

  { TAlignPalette }
  if FindWindow(AlignPaletteWindowClass.lpszClassName,'Align') = 0 then begin
     RegisterClass(AlignPaletteWindowClass);
     AlignPaletteHWND := CreateWindowEx(0,AlignPaletteWindowClass.lpszClassName,'ALIGN',0,0,0,0,0,0,0,HInstance,NIL);
  end;
End;

finalization
Begin
  { TApplication }
  UnregisterClass(ApplicationWindowClass.lpszClassName, HInstance);
  if ApplicationHWND <> 0 then DestroyWindow(ApplicationHWND);

  { TAppBuilder }
  UnregisterClass(AppBuilderWindowClass.lpszClassName, HInstance);
  if AppBuilderHWND <> 0 then DestroyWindow(AppBuilderHWND);

  { TPropertyInspector }
  UnregisterClass(PropertyInspectorWindowClass.lpszClassName, HInstance);
  if PropertyInspectorHWND <> 0 then DestroyWindow(PropertyInspectorHWND);

  { TAlignPalette }
  UnregisterClass(AlignPaletteWindowClass.lpszClassName, HInstance);
  if AlignPaletteHWND <> 0 then DestroyWindow(AlignPaletteHWND);
End;

end.

